<html>
<div id="myheader">
<?php
        include "include/top.php"
?>
</div>


<title>OSPMS</title>
<head>

<style type="text/css" media="all">


#mymenu{ MARGIN: 10px 10px 10px 10px;
PADDING:10px 10px 10px 10px;
BORDER-TOP: #CCC 2px solid;
BORDER-RIGHT: #CCC 2px solid;
BORDER-BOTTOM: #CCC 2px solid;
BORDER-LEFT: #CCC 2px solid;
BACKGROUND: url(images/bg_poem.jpg) #FEFEFE no-repeat right bottom;
COLOR: #666;
TEXT-ALIGN: left;
LINE-HEIGHT: 250%; WIDTH:12%; }

#mybody{ POSITION: absolute;
LEFT:300px;
TOP:100px;
WIDTH:900px;
MARGIN: 0px;
PADDING: 0px;
BACKGROUND: #DADADA;
}
#right{ POSITION: absolute;
LEFT:1200px;
TOP:100px;
WIDTH:200px;
MARGIN: 0px;
PADDING: 0px;
BACKGROUND: #FFF; }

 .regtable{width:600px;background:#fff;border-radius:5px;padding-top:30px;padding-bottom:100px}
 .regtable th{font-size:26px;color:#9c9c9c}  <!-- slightly darker than gray -->
 .regtable td{padding: 6px;}
 .regtable td a{color: green;}
 .regtable .lefttd{text-align: right;width:25%;color:gray}
 .regtable .righttd{text-align: left;width:75%}
 .regtable .text{width:58%;border: solid 1px #ddd;height:34px;line-height: 34px;background: #f5f5f5;border-radius:5px} 
<!-- #cmdLogin{width: 200px;height:40px;text-align:center;color:#fff;border:0;background: #e96481;border-radius: 5px;} -->
 #cmdLogin{width: 200px;height:40px;text-align:center;color:#fff;border:0;background: #e96481;border-radius: 5px;} 
a,a:visited {color:#333;text-decoration:none;}
a:hover {color:#f60;}
body,td {font:13px "Geneva","Arial", "Arial", "Helvetica",sans-serif;}
ul,li {margin:0;padding:0;list-style:none;}
h1,h2,h3,h4,h5,h6 {margin:0;padding:0;}
h1 {padding:5px;color:#900;font:16px bold "Geneva","ËÎÌå", "Arial", "Helvetica",sans-serif;}
h1 small {font-size:11px;font-weight:normal;color:#660;}

.TreeWrap {width:160px;}
.MenuBox .titBox a,
.MenuBox .titBox a:visited,
.MenuBox2 .titBox a,
.MenuBox2 .titBox a:visited {margin-left:2px;padding-left:3px;color:#003;font-size:12px;display:block;}
.MenuBox .titBox h3 a {background:url(images/ico_folder_open.gif) no-repeat 0 40%;}
.MenuBox .titBox h3.Fst a {background:url(images/ico_folder_open_fst.gif) no-repeat 0 40%;}
.MenuBox .titBox h3.Lst a {background:url(images/ico_folder_open_lst.gif) no-repeat 0 40%;}
.MenuBox2 .titBox h3 a {background:url(images/ico_folder.gif) no-repeat 0 40%;}
.MenuBox2 .titBox h3.Fst a {background:url(images/ico_folder_fst.gif) no-repeat 0 40%;}
.MenuBox2 .titBox h3.Lst a {line-height:250%;background:url(images/icon_exit.gif) no-repeat 0 0;}
.MenuBox2 .txtBox {display:none;}
.MenuBox .txtBox ul li {padding-left:20px;line-height:150%;}
.MenuBox .txtBox .num {color:#e00;}
.MenuBox .txtBox ul {background:url(images/line_y.gif) repeat-y 16px 0;}
.MenuBox .txtBox ul li {background:url(images/t.gif) no-repeat 28px 50%;}
.MenuBox .txtBox ul li.Lst {background:url(images/t_lst.gif) no-repeat 28px 50%;}
</style>


<script type="text/javascript">
<!--
 function ExChgClsName(Obj,NameA,NameB){
  var Obj=document.getElementById(Obj)?document.getElementById(Obj):Obj;
  Obj.className=Obj.className==NameA?NameB:NameA;
 }
 function showMenu(iNo){
 ExChgClsName("Menu_"+iNo,"MenuBox","MenuBox2");
 }
-->
</script>
</head>


<div id="mymajorbody">

<div id="mymenu">
<body>

<div class="TreeWrap">
<div class="MenuBox" id="Menu_0">
<div class="titBox"><h3 class="Fst"><a href="javascript:showMenu(0);">Setting</a></h3></div>
<div class="txtBox">
 <ul>
  <li><a href="/OSPMS/Project.php">Project</a></li>
  <li><a href="/OSPMS/Project.php">Project</a></li>
  <li><a href="/OSPMS/Project.php">Project</a></li>
  <li class="Lst"><a href="/OSPMS/Study.php">Study</a></li>
 </ul>
</div>
</div><!--MenuBox-->
<div class="MenuBox2" id="Menu_1">
<div class="titBox"><h3><a href="javascript:showMenu(1);">Project</a></h3></div>
<div class="txtBox">
 <ul>
  <li><a href="/OSPMS/ShowProjects.php">Show</a></li>
  <li><a href="/OSPMS/Upload_Project.php">Upload</a></li>
  <li class="Lst"><a href="#">J</a></li>
 </ul>
</div>
</div><!--MenuBox-->
<div class="MenuBox2" id="Menu_2">
<div class="titBox"><h3><a href="javascript:showMenu(2);">Program</a></h3></div>
<div class="txtBox">
 <ul>
  <li><a href="#">Todo</a></li>
  <li class="Lst"><a href="#">M</a></li>
 </ul>
</div>
</div><!--MenuBox-->
<div class="MenuBox2" id="Menu_3">
<div class="titBox"><h3><a href="javascript:showMenu(3);">My Document</a></h3></div>
<div class="txtBox">
 <ul>
  <li><a href="#">Todo</a></li>
  <li class="Lst"><a href="#">R</a></li>
 </ul>
</div>
</div><!--MenuBox-->
<div class="MenuBox" id="Menu_0">
<div class="titBox"><h3 class="Fst"><a href="javascript:showMenu(0);">Admin</a></h3></div>
<div class="txtBox">
 <ul>
  <li><a href="#">Audit Log</a></li>
  <li class="Lst"><a href="#">Sign-in Log</a></li>
 </ul>
</div>
</div>


</div>

<div id="mybody">


<!--
<form method="post" action="<?php $_PHP_SELF ?>">
<table class="mytable regtable">
    <tr>
      <th></th>
      <th class="righttd">Project Settings</th>

    </tr>
    <tr>
      <td class="lefttd">cust_id:</td>
      <td class="righttd"><input type="text" name="cust_id" class="text"/></td>
    </tr>
    <tr>
      <td class="lefttd">Input1:</td>
      <td class="righttd"><input type="text" name="Input1" class="text"/></td>
    </tr>
    <tr>
      <td class="lefttd">Input3:</td>
      <td class="righttd"><input type="text" name="Input3" class="text"/></td>
    </tr>
    <tr>
      <td></td>
      <td class="righttd">
        <input type="submit" value="Submit" name="add" id="cmdLogin"/>
      </td>
    </tr>
</table>
</form>
-->



<?php

echo "<table style='border: solid 1px black;'>";
//echo "<tr><th>Id</th><th>Firstname</th><th>Lastname</th><th>Email</th><th>Reg date</th></tr>"; -

$servername = "localhost";
$username = "ospms";
$password = "ospms";
$dbname = "OSPMS";


class TableRows extends RecursiveIteratorIterator {
    function __construct($it) {
        parent::__construct($it, self::LEAVES_ONLY);
    }

    function current() {
        return "<td style='width:150px;border:1px solid black;'>" . parent::current(). "</td>";
    }

    function beginChildren() {
        echo "<tr>";
    }

    function endChildren() {
        echo "</tr>" . "\n";
    }
}


try {
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);


$select = $conn->query('SELECT * FROM user_project');

$total_column = $select->columnCount();
//var_dump($total_column);

for ($counter = 0; $counter <= $total_column; $counter ++) {
    $meta = $select->getColumnMeta($counter);
    $column[] = $meta['name'];
}
//print_r($column);


$stmt = $conn->prepare("DESCRIBE user_project");
$stmt->execute();
$table_fields = $stmt->fetchAll(PDO::FETCH_COLUMN);
//print_r($table_fields);

	echo "<tr>". " \n";
for ( $i=0 ; $i<count($table_fields); $i++ ) {
	echo "<td>" ;
	print_r($table_fields[$i]);
	echo "</td>" ;
}
	echo "</tr>". " \n";

    $stmt = $conn->prepare("SELECT * FROM user_project");
    $stmt->execute();
    // set the resulting array to associative
    $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);

    foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
        echo $v;
    }
    $dsn = null;
    }
catch(PDOException $e)
    {
    echo "Error: " . $e->getMessage();
    }
$conn = null;
echo "</table>";
?> 

</div>
</div>


<div id="myfooter">
<?php
        include "include/bottom.php"
?>
</div>
